package com.hhs.storage.controller;


import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.hhs.storage.bean.*;
import com.hhs.storage.service.NotepadOtherService;
import com.hhs.storage.service.NotepadService;
import com.hhs.storage.service.NoticeService;
import com.hhs.storage.util.DateEasy;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import liquibase.pro.packaged.R;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hhs
 * @since 2023-06-13
 */
@RestController
@RequestMapping("note")
@ApiSupport(order = 5)      //排序
@Api(tags = "备忘录管理接口")
public class NotepadController {
    @Resource
    private NotepadService notepadService;
    @Resource
    private NotepadOtherService notepadOtherService;
    @RequestMapping(value = "table")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "得到表格数据增加时间条件，其它参数未写要正常保留",
            notes = "得到表格数据增加时间条件，其它参数未写要正常保留",
            httpMethod = "POST"
    )
    @ApiImplicitParams({
            @ApiImplicitParam(dataTypeClass = String.class,name = "searchTime", value = "时间",required =
                    false,paramType = "query"),
            @ApiImplicitParam(dataTypeClass = String.class,name = "userId", value = "查询用户id",required =
                    false,paramType = "query")
    })
    public Map<String, Object> getAll(@ApiIgnore Notepad notepad, @ApiIgnore InputParam inputParam) {
        return notepadService.getAll(notepad,inputParam);
    }
    @PostMapping(value = "edit")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "日程带有创建时间，传入时间是多少创建时间就是多少,增加的参数其它参数要照带",
            notes = "日程带有创建时间，传入时间是多少创建时间就是多少,增加的参数其它参数要照带",
            httpMethod = "POST"
    )
    @ApiImplicitParams({
            @ApiImplicitParam(dataTypeClass = LocalDateTime.class,name = "createTimeStartTime", value = "创建时间",required =
                    false,paramType = "query"),
            @ApiImplicitParam(dataTypeClass = String.class,name = "userId", value = "用户id",required =
                    false,paramType = "query")
    })
    public Map<String, Object> addOrUpdate(@ApiIgnore Notepad notepad,@ApiIgnore InputParam inputParam){
        return notepadService.addOrUpdate(notepad,inputParam);
    }
    @RequestMapping(value = "getCalendarDatas")
    public Map<String, Object> getCalendarDatas(InputParam inputParam){
        return notepadService.getCalendarDatas(inputParam);
    }
    /**
     * 新增补充完整犨
     * @param leaderTask 内容
     * @return
     */
    @PostMapping(value = "fullinfo")
    public Map<String, Object> fullinfo(@RequestBody Map<String,Object> leaderTask){
        System.out.println("=================="+leaderTask);
//        String leaderTaskStartDate = new DateEasy(Long.parseLong(leaderTask.get("LeaderTaskStartDate") + "")).toYYYYhMMhDDhHHcMMcSS();
//        String leaderTaskEndDate = new DateEasy(Long.parseLong(leaderTask.get("leaderTaskEndDate") + "")).toYYYYhMMhDDhHHcMMcSS();
//        leaderTask.put("LeaderTaskEndDate",leaderTaskEndDate);
//        leaderTask.put("leaderTaskStartDate",leaderTaskStartDate);
        return notepadService.saveOther(leaderTask);
    }
    /**
     * 新增补充完整犨
     * @param inputParam
     * @return
     */
    @PostMapping(value = "getfullinfo")
    public Map<String, Object> getfullinfo(InputParam inputParam){
        return notepadService.getfullinfo(inputParam);
    }
    @RequestMapping(value = "dele")
    public Map<String, Object> dele(@RequestParam Integer id) {
        return notepadService.dele(id);
    }

    @RequestMapping(value = "deleAll")
    public Map<String, Object> deleAll(InputParam inputParam) {
        return notepadService.deleAll(inputParam);
    }
    @PostMapping(value = "complete")
    public Map<String, Object> complete(Integer id){
        return notepadService.complete(id);
    }

    //记事本事项设置闹钟提醒
    @PostMapping(value = "remind")
    public Map<String, Object> remind(Notepad notepad){
        return notepadService.remind(notepad);
    }

    //查询需要提醒的数据
    @PostMapping(value = "remindMe")
    public Map<String, Object> remindMe( ){
        return notepadService.remindMe();
    }

    //工序的修改
    @PostMapping(value = "wkEdit")
    public Map<String, Object> wkEdit(@RequestBody Notepad notepad){
        return notepadService.wkEdit(notepad);
    }
    //工序的查询
    @PostMapping(value = "wkQuery")
    public Map<String, Object> wkQuery( Notepad notepad){
        return notepadService.wkQuery(notepad);
    }

    @PostMapping(value = "sort")
    public Map<String,Object> updateSort(@RequestBody List<SortBean> sortList){
        return notepadService.updateSort(sortList);
    }

    @PostMapping(value = "stateChange")
    public Map<String,Object> stateChange(String id,Integer state){
        return notepadService.stateChange(id,state);
    }


}


